package com.dataeco.api.service.impl;

import com.dataeco.api.entity.User;
import com.dataeco.api.security.SecurityUserDetails;
import com.dataeco.api.service.BaseService;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;


public class BaseServiceImpl implements BaseService {
    @Override
    public Authentication getAuthentication() {
        return SecurityContextHolder.getContext().getAuthentication();
    }

    @Override
    public SecurityUserDetails getUserDetails() {
        return (SecurityUserDetails) getAuthentication().getPrincipal();
    }

    @Override
    public User getUser() {
        return getUserDetails().getUser();
    }

    @Override
    public String getUserId() {
        return getUserDetails().getUserId();
    }


}
